
<%@page import="entity.M_user"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<% 
	M_user user=(M_user)session.getAttribute("userInfo");
	if(user!=null){
	if(user.getM_username()==null||!"admin".equals(user.getM_username())){
	response.sendRedirect("movie.do");
	return;
	}
	}else{
		response.sendRedirect("movie.do");
	}
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>管理后台</title>
<style type="text/css">
	*{margin:0;padding:0;}
	li{ list-style-type:none;}
	a:link{color:#5fb701;}
	a:visited{color:#5fb701;}
	a:hover{color:blue;}
	a:active{color:black; }
	#xianShi #x2,#x3{display: none;}
	
	table tr td{text-align: center;}
	
	span{ border-right:#898989 solid 1px;display:block;float:right;height:14px;margin-top:5px;
	margin-right:10px;margin-left:10px;}
	#footer{width: 847px;margin:0 auto;overflow:hidden;}
	#b1{width:400px;margin:0 auto;height:24px;line-height:24px;text-align:center;margin-top:30px;}
	#b1 ul{overflow:hidden;}
	#b1 li{float:left;}
	#b2{width:530px;margin:0 auto;font-size:12px;margin-top:15px;}
	#b3{width:210px;overflow:hidden;margin:0 auto;padding-top:15px;margin-bottom:30px; }
	#b3 img{float:left;padding-right:10px;}
</style>
<script type="text/javascript" src="js/jquery-1.8.3.js"></script>
<script type="text/javascript">
	
	$(function(){
		$("#head #headTab #movie").click(function(){
			$("#x1").show().siblings().hide();
		});
		$("#head #headTab #comm").click(function(){
			$("#x2").show().siblings().hide();
		});
		$("#head #headTab #user").click(function(){
			$("#x3").show().siblings().hide();
		});
		
		$("#select").click(function(){
			$("#x2").show().siblings().hide();
		});
		
		
		
		//显示评论的方法
		function sel(data){
		var tr="";
		for(i=0;i<data.length;i++){
					var sss=data[i];
					tr+="<tr><td class='cid'  style='text-align: center;width: 80px;'>"+sss.id+"</td>"+
					"<td style='text-align: center;width: 70px;'>"+sss.score+"</td>"+
					"<td style='text-align: center;width: 200px;'>"+sss.m_comment+"</td>"+
					"<td style='text-align: center;width: 170px;'>"+sss.moviename+"</td>"+
					"<td style='text-align: center;width: 170px;'>"+sss.username+"</td>"+
					"<td style='text-align: center;'><input type='button' id='"+sss.id+"' value='删除'/></td>"+
				"</tr>";
				$("#result2").html(tr);
				}
		
	};
		
		
		//查询评论
		$("#select2").click(function(){
		
		var movie=$("#movie2").val();
		var uname=$("#uname2").val();
		
		movie=encodeURI(encodeURI(movie));
		uname=encodeURI(encodeURI(uname));
		var tr="";
			$.post(
				"comm.do?action=AdminComm&movie="+movie+"&uname="+uname,
				function(data){
				sel(data);
				$(".table tr:odd").css({"background-color":"#fdfdfd","color":"black"});
			},
				"json"
			);
		
		});
		
		
		
		//删除评论
		$("#result2 input[type=button]").live('click',function(){
			var cid=$(this).parent().parent().children().eq(0).html();
			$.post(
				"comm.do?action=delComment&id="+cid,
				function(data){
				
				var tr="";
		for(i=0;i<data.length;i++){
					var sss=data[i];
					tr+="<tr><td class='cid'  style='text-align: center;width: 80px;'>"+sss.id+"</td>"+
					"<td style='text-align: center;width: 70px;'>"+sss.score+"</td>"+
					"<td style='text-align: center;width: 200px;'>"+sss.m_comment+"</td>"+
					"<td style='text-align: center;width: 170px;'>"+sss.moviename+"</td>"+
					"<td style='text-align: center;width: 170px;'>"+sss.username+"</td>"+
					"<td style='text-align: center;'><input type='button' id='"+sss.id+"' value='删除'/></td>"+
				"</tr>";
				$("#result2").html(tr);
				}
				$(".table tr:odd").css({"background-color":"#fdfdfd","color":"black"});
				},
				"json"
			);
		});
		
		//查询用户信息
		$("#select3").click(function(){
			var movie3=$("#movie3").val();
			movie3=encodeURI(encodeURI(movie3));
			$.post(
				"user.do?action=findUserAllorByn&movie3="+movie3,
				function(data){
					var tr="";
					for(i=0;i<data.length;i++){
						var s=data[i];
						tr+="<tr><td style='width: 60px;text-align: center;'>"+s.id+"</td>"+
						"<td style='width: 100px;text-align: center;'>"+s.m_username+"</td>"+
						"<td style='width: 100px;text-align: center;'>"+s.password+"</td>"+
						"<td style='width: 60px;text-align: center;'>"+s.gender+"</td>"+
						"<td style='width: 60px;text-align: center;'>"+s.score+"</td>"+
						"<td style='width: 140px;text-align: center;'>"+s.phone+"</td>"+
						"<td style='width: 200px;text-align: center;'>"+s.email+"</td>"+
						"<td style='text-align: center;'><input type='button' name='' id='"+s.id+"' value='删除'/></td></tr>";
						$("#result3").html(tr);
					}
					$(".table tr:odd").css({"background-color":"#fdfdfd","color":"black"});
				},
				"json"
			
			);
		
		});
		
		//删除用户信息
		$("#result3 input[type=button]").live('click',function(){
			var cid=$(this).parent().parent().children().eq(0).html();
			
			$.post(
				"user.do?action=delUserByAdmin&id="+cid,
				function(data){
				
				var tr="";
		for(i=0;i<data.length;i++){
					var s=data[i];
		tr+="<tr><td style='width: 60px;text-align: center;'>"+s.id+"</td>"+
						"<td style='width: 100px;text-align: center;'>"+s.m_username+"</td>"+
						"<td style='width: 100px;text-align: center;'>"+s.password+"</td>"+
						"<td style='width: 60px;text-align: center;'>"+s.gender+"</td>"+
						"<td style='width: 60px;text-align: center;'>"+s.score+"</td>"+
						"<td style='width: 140px;text-align: center;'>"+s.phone+"</td>"+
						"<td style='width: 200px;text-align: center;'>"+s.email+"</td>"+
						"<td text-align: center;'><input type='button' name='' value='删除'/></td></tr>";
						$("#result3").html(tr);
					}
					$(".table tr:odd").css({"background-color":"#fdfdfd","color":"black"});
				},
				"json"
			
			);
		
		});
		$(".table tr:odd").css({"background-color":"#fdfdfd","color":"black"});
	});
	
	
</script>
<style type="text/css">
	#table tr td{border: 1px #005566 solid;text-align: center;}
	#table{}
</style>
</head>
<body style="width: 847px;background-color: #3f444e;color: white;margin: 0 auto;">
<div id="header">
	
    <div id="nav" style="position: relative;margin-top: 20px;">
    	<div id="welcome" style="position: absolute;top: 10px;">欢迎使用电影天堂管理系统！</div>
        <div id="a_b01"><img src="img/imgs/login_04.gif"></img></div>
    </div>
</div>
<div style="width: 842px;">
	<div id="head">
		<table id="headTab">
			<tr>
				<td><input type="button" name="movie" id="movie" value="电影管理"/></td>
				<td><input type="button" name="comm" id="comm" value="评论管理"/></td>
				<td><input type="button" name="user" id="user" value="用户管理"/></td>
			</tr>
		</table>
	</div>
	<div id="xianShi" style="height: 800px;">
		<div id="x1">
			<div>
				<table>
					<tr>
						<td><a href="addMovie.jsp">新增</a></td>
					</tr>
				</table>
			</div>
			<div id="L1">
			
		<form action="movie.do?action=findByAdmin" method="post" name="movieForm">
		<div style="width: 600px;margin: 0 auto;">
			<table>
				<tr>
					<td>请输入电影名：</td>
					<td><input type="text" name="movie" id="movie"/></td>
					<td>请输入导演名：</td>
					<td><input type="text" name="director" id="director"/></td>
					<td><input type="submit" name="select" id="select" value="查询"/></td>
				</tr>
			</table>
			</div>
			<table class="table" style="border-collapse:10px;">
				<tr>
					<td style="text-align: center;">电影id</td>
					<td style="text-align: center;">电影名</td>
					<td style="text-align: center;">导演</td>
					<td style="text-align: center;">演员</td>
					<td style="text-align: center;">时长</td>
					<td style="text-align: center;">电影地区</td>
					<td style="text-align: center;">电影类型</td>
					<td style="text-align: center;">电影评分</td>
					<td style="text-align: center;">操作</td>
					<td style="color: red;">${delError}</td>
				</tr>
				<c:forEach items="${selMovie}" var="i" varStatus="v">
				<tr>
					<td><a href="movie.do?action=updateMovieBack&id=${i.id}">${i.id}</a></td>
					<td style="width: 175px;text-align: center;">${i.moviename}</td>
					<td style="width: 155px;text-align: center;">${i.dictor}</td>
					<td style="width: 155px;text-align: center;">${i.actor}</td>
					<td style="width: 40px;text-align: center;">${i.time}</td>
					<c:choose>
						<c:when test="${i.type==1}"><td>爱情</td></c:when>
						<c:when test="${i.type==2}"><td>喜剧</td></c:when>
						<c:when test="${i.type==3}"><td>动画</td></c:when>
						<c:when test="${i.type==4}"><td>剧情</td></c:when>
						<c:when test="${i.type==5}"><td>科幻</td></c:when>
						<c:when test="${i.type==6}"><td>恐怖</td></c:when>
						<c:when test="${i.type==7}"><td>战争</td></c:when>
						<c:when test="${i.type==8}"><td>犯罪</td></c:when>
					</c:choose>
					
					<c:choose>
						<c:when test="${i.area==1}"><td>大陆</td></c:when>
						<c:when test="${i.area==2}"><td>香港</td></c:when>
						<c:when test="${i.area==3}"><td>台湾</td></c:when>
						<c:when test="${i.area==4}"><td>韩国</td></c:when>
						<c:when test="${i.area==5}"><td>日本</td></c:when>
						<c:when test="${i.area==6}"><td>欧美</td></c:when>
					</c:choose>
					<td>${i.score}</td>
					<td><a href="movie.do?action=delMovie&id=${i.id}">删除</a></td>
					
				</tr>
				</c:forEach>
			</table>
		</form>
		</div>
		</div>
		<div id="x2">
			
			<div style="width: 600px;margin: 0 auto;">
			<form action="comm.do?action=AdminComm" method="post" name="commForm">
			<table>
				<tr>
					<td>请输入电影名：</td>
					<td><input type="text" name="movie2" id="movie2"/></td>
					<td>请输入用户名：</td>
					<td><input type="text" name="uname2" id="uname2"/></td>
					<td><input type="button" name="select2" id="select2" value="查询"/></td>
				</tr>
			</table>
			</form>
			</div>
			
			<div id="L2">
			<table class="table" >
				<tr>
					<td style="width: 80px;text-align: center;">评论id</td>
					<td style="width: 70px;text-align: center;">评分</td>
					<td style="width: 200px;text-align: center;">评论</td>
					<td style="width: 170px;text-align: center;">电影名字</td>
					<td style="width: 170px;text-align: center;">用户名</td>
					<td style="text-align: center;">操作</td>
				</tr>
			</table>
			<table class="table" id="result2" style="border-collapse:10px;">
				
			</table>
		</div>
		</div>
		<div id="x3">
			<div id="L3">
			<form action="">
				<div style="width: 350px;margin: 0 auto;">
					<table>
						<tr>
							<td>请输入用户名：</td>
							<td><input type="text" name="movie3" id="movie3"/></td>
							<td><input type="button" name="select3" id="select3" value="查询"/></td>
						</tr>
					</table>
				</div>
			</form>
			<table>
				<tr>
					<td style="width: 60px;text-align: center;">用户id</td>
					<td style="width: 100px;text-align: center;">用户名</td>
					<td style="width: 100px;text-align: center;">密码</td>
					<td style="width: 60px;text-align: center;">性别</td>
					<td style="width: 60px;text-align: center;">积分</td>
					<td style="width: 140px;text-align: center;">电话</td>
					<td style="width: 200px;text-align: center;">邮箱</td>
					<td style="text-align: center;">操作</td>
				</tr>
			</table>
			<table class="table" id="result3" style="border-collapse:10px;">
				
				
			</table>
		</div>
		</div>
	</div>
	<div id="lieBiao">
	
		
		
		
	</div>
	
</div>	
	
	
	<div id="footer">
		<div id="b1">
            	<ul>
                	<li><a href="movie.do">首页</a><span></span></li>
	                <li><a href="#">客户服务</a><span></span></li>
	                <li><a href="#">品牌合作</a><span></span></li>
	                <li><a href="#">网站联盟</a><span></span></li>
	                <li><a href="#">投诉与建议</a></li>
                </ul>
            </div>
		<div id="b2">
            	<p>copyright&copy;2011 vijia.com All Rights Reserved京ICP备08800757号 京公网安备110105005426</p>
            </div>
            <div id="b3">
            	<ul>
                    <li><img src="img/imgs/btm_logo_1.gif" /></li>
                    <li><img src="img/imgs/btm_logo_2.gif" /></li>
            	</ul>
            </div>
	</div>


</body>
</html>